//
//  AddLadingBillStatusView.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/2.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "AddLadingBillStatusView.h"

@interface AddLadingBillStatusView ()

@property (nonatomic, strong) UIButton *oneBtn;
@property (nonatomic, strong) UILabel *infoLab;
@property (nonatomic, strong) UIButton *twoBtn;
@property (nonatomic, strong) UILabel *listLab;
@property (nonatomic, strong) UIButton *threeBtn;
@property (nonatomic, strong) UILabel *requireLab;
@property (nonatomic, strong) UILabel *line1;
@property (nonatomic, strong) UILabel *line2;

@end

@implementation AddLadingBillStatusView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HexColor(0xffffff);
        
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 1)];
        line.backgroundColor = HexColor(0xF2F2F5);
        [self addSubview:line];
        
        CGFloat labW = ScreenW * 0.333333;
        CGFloat labH = 13;
        CGFloat numberW = 24;
        
        self.infoLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 49, labW, labH)];
        self.infoLab.text = @"填写基本信息";
        self.infoLab.textColor = Color_ThemeColor;
        self.infoLab.font = BoldFontOfSize(12);
        self.infoLab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.infoLab];
        
        self.listLab = [[UILabel alloc] initWithFrame:CGRectMake(self.infoLab.nim_right, self.infoLab.nim_top, labW, labH)];
        self.listLab.text = @"填写提货清单";
        self.listLab.textColor = HexColor(0x9C9DB3);
        self.listLab.font = BoldFontOfSize(12);
        self.listLab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.listLab];
        
        self.requireLab = [[UILabel alloc] initWithFrame:CGRectMake(self.listLab.nim_right, self.infoLab.nim_top, labW, labH)];
        self.requireLab.text = @"设置运输要求";
        self.requireLab.textColor = HexColor(0x9C9DB3);
        self.requireLab.font = BoldFontOfSize(12);
        self.requireLab.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.requireLab];
        
        self.oneBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, (49 - numberW) * 0.5, numberW, numberW)];
        [self.oneBtn setTitle:@"1" forState:0];
        [self.oneBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.oneBtn.titleLabel.font = BoldFontOfSize(14);
        [self.oneBtn setBackgroundColor:Color_ThemeColor];
        self.oneBtn.layer.masksToBounds = YES;
        self.oneBtn.layer.cornerRadius = numberW * 0.5;
        [self addSubview:self.oneBtn];
        self.oneBtn.nim_centerX = self.infoLab.nim_centerX;
        
        self.twoBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, (49 - numberW) * 0.5, numberW, numberW)];
        [self.twoBtn setTitle:@"2" forState:0];
        [self.twoBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        self.twoBtn.titleLabel.font = BoldFontOfSize(14);
        [self.twoBtn setBackgroundColor:HexColor(0xDBDCE6)];
        self.twoBtn.layer.masksToBounds = YES;
        self.twoBtn.layer.cornerRadius = numberW * 0.5;
        [self addSubview:self.twoBtn];
        self.twoBtn.nim_centerX = self.listLab.nim_centerX;
        
        self.threeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, (49 - numberW) * 0.5, numberW, numberW)];
        [self.threeBtn setTitle:@"3" forState:0];
        [self.threeBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        self.threeBtn.titleLabel.font = BoldFontOfSize(14);
        [self.threeBtn setBackgroundColor:HexColor(0xDBDCE6)];
        self.threeBtn.layer.masksToBounds = YES;
        self.threeBtn.layer.cornerRadius = numberW * 0.5;
        [self addSubview:self.threeBtn];
        self.threeBtn.nim_centerX = self.requireLab.nim_centerX;
        
        self.line1 = [[UILabel alloc] initWithFrame:CGRectMake(self.oneBtn.nim_right + 8, self.oneBtn.nim_centerY-1, self.twoBtn.nim_left-8-(self.oneBtn.nim_right + 8), 2)];
        self.line1.backgroundColor = HexColor(0xF2F2F5);
        [self addSubview:self.line1];
        
        self.line2 = [[UILabel alloc] initWithFrame:CGRectMake(self.twoBtn.nim_right + 8, self.twoBtn.nim_centerY-1, self.threeBtn.nim_left-8-(self.twoBtn.nim_right + 8), 2)];
        self.line2.backgroundColor = HexColor(0xF2F2F5);
        [self addSubview:self.line2];
        
    }
    return self;
}

-(void)setStatus:(AddLadingBillStatus)status {
    _status = status;
    if (status == AddLadingBillStatusInfo) {
        self.infoLab.textColor = Color_ThemeColor;
        [self.oneBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.oneBtn setBackgroundColor:Color_ThemeColor];
        
        self.listLab.textColor = HexColor(0x9C9DB3);
        [self.twoBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        [self.twoBtn setBackgroundColor:HexColor(0xDBDCE6)];
        
        self.requireLab.textColor = HexColor(0x9C9DB3);
        [self.threeBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        [self.threeBtn setBackgroundColor:HexColor(0xDBDCE6)];
    }else if (status == AddLadingBillStatusList) {
        self.infoLab.textColor = Color_ThemeColor;
        [self.oneBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.oneBtn setBackgroundColor:Color_ThemeColor];
        
        self.listLab.textColor = Color_ThemeColor;
        [self.twoBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.twoBtn setBackgroundColor:Color_ThemeColor];
        
        self.requireLab.textColor = HexColor(0x9C9DB3);
        [self.threeBtn setTitleColor:HexColor(0x2B2C44) forState:0];
        [self.threeBtn setBackgroundColor:HexColor(0xDBDCE6)];
    }else if (status == AddLadingBillStatusRequire) {
        self.infoLab.textColor = Color_ThemeColor;
        [self.oneBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.oneBtn setBackgroundColor:Color_ThemeColor];
        
        self.listLab.textColor = Color_ThemeColor;
        [self.twoBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.twoBtn setBackgroundColor:Color_ThemeColor];
        
        self.requireLab.textColor = Color_ThemeColor;
        [self.threeBtn setTitleColor:HexColor(0xffffff) forState:0];
        [self.threeBtn setBackgroundColor:Color_ThemeColor];
    }
}

@end
